<default>["<Shift>Print"]</default>
<summary>Take a screenshot</summary>
</key>
+ <key name="screen-brightness-up" type="as">
+ <default>['XF86MonBrightnessUp']</default>
+ <summary>Screen brightness up</summary>
+ </key>
+ <key name="screen-brightness-up-monitor" type="as">
+ <default>['<Shift>XF86MonBrightnessUp']</default>
+ <summary>Screen brightness up on current monitor</summary>
+ </key>
+ <key name="screen-brightness-down" type="as">
+ <default>['XF86MonBrightnessDown']</default>
+ <summary>Screen brightness down</summary>
+ </key>
+ <key name="screen-brightness-down-monitor" type="as">
+ <default>['<Shift>XF86MonBrightnessDown']</default>
+ <summary>Screen brightness down on current monitor</summary>
+ </key>
+ <key name="screen-brightness-cycle" type="as">
+ <default>['XF86MonBrightnessCycle']</default>
+ <summary>Screen brightness cycle</summary>
+ </key>
+ <key name="screen-brightness-cycle-monitor" type="as">
+ <default>['<Shift>XF86MonBrightnessCycle']</default>
+ <summary>Screen brightness cycle on current monitor</summary>
+ </key>
</schema>
<schema id="org.gnome.shell.app-switcher"
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
+import Meta from 'gi://Meta';
+import Shell from 'gi://Shell';
import * as Main from '../ui/main.js';
+const SCALE_VALUE_STEP = 0.1;
const SCALE_VALUE_CHANGE_EPSILON = 0.001;
+const KEYBINDING_SCHEMA = 'org.gnome.shell.keybindings';
const POWER_SCHEMA = 'org.gnome.settings-daemon.plugins.power';
export const BrightnessManager = GObject.registerClass({
this._abTarget = -1.0;
+ Main.wm.addKeybinding(
+ 'screen-brightness-up',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessUp.bind(this));
+
+ Main.wm.addKeybinding(
+ 'screen-brightness-up-monitor',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessUpCurrentMonitor.bind(this));
+
+ Main.wm.addKeybinding(
+ 'screen-brightness-down',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessDown.bind(this));
+
+ Main.wm.addKeybinding(
+ 'screen-brightness-down-monitor',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessDownCurrentMonitor.bind(this));
+
+ Main.wm.addKeybinding(
+ 'screen-brightness-cycle',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessCycle.bind(this));
+
+ Main.wm.addKeybinding(
+ 'screen-brightness-cycle-monitor',
+ new Gio.Settings({schema_id: KEYBINDING_SCHEMA}),
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this._screenBrightnessCycleCurrentMonitor.bind(this));
+
const monitorManager = global.backend.get_monitor_manager();
monitorManager.connectObject('monitors-changed',
this._monitorsChanged.bind(this), this);
return [...this._monitorScales.values()];
}
+ _screenBrightnessUp() {
+ this._globalScale?.stepUp();
+ }
+
+ _screenBrightnessUpCurrentMonitor() {
+ const monitor = global.backend.get_current_logical_monitor();
+ this._monitorScales.get(monitor)?.stepUp();
+ }
+
+ _screenBrightnessDown() {
+ this._globalScale?.stepDown();
+ }
+
+ _screenBrightnessDownCurrentMonitor() {
+ const monitor = global.backend.get_current_logical_monitor();
+ this._monitorScales.get(monitor)?.stepDown();
+ }
+
+ _screenBrightnessCycle() {
+ this._globalScale?.cycleUp();
+ }
+
+ _screenBrightnessCycleCurrentMonitor() {
+ const monitor = global.backend.get_current_logical_monitor();
+ this._monitorScales.get(monitor)?.cycleUp();
+ }
+
_monitorsChanged() {
const monitors = global.backend
.get_monitor_manager()
this.notify('locked');
}
+ stepUp() {
+ this._setValue(Math.min(1.0, this._brightness + SCALE_VALUE_STEP));
+ }
+
+ stepDown() {
+ this._setValue(Math.max(0.0, this._brightness - SCALE_VALUE_STEP));
+ }
+
+ cycleUp() {
+ if (Math.abs(1.0 - this._brightness) < SCALE_VALUE_CHANGE_EPSILON)
+ this._setValue(0.0);
+ else
+ this.stepUp();
+ }
+
_setValue(value) {
value = Math.clamp(value, 0.0, 1.0);
if (Math.abs(value - this._value) < SCALE_VALUE_CHANGE_EPSILON)